home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-30 | 3.7 KB | 95 lines | [TEXT/MPS ] |
- {[j=20/53/1$] Pasmat Options}
-
- UNIT UAreaSelector;
-
- {-------------------------------------------------------------------------------------------
-
- Program: FracApp 2.0
- Unit: UAreaSelector
- File: UAreaSelector.p
- Includes: UAreaSelector,inc1.p
-
- by Keith Rollin & Bo3b Johnson
- of Apple Macintosh Developer Technical Support
-
- Copyright © 1988-1990 Apple Computer, Inc.
- All rights reserved.
-
- --------------------------------------------------------------------------------------------
-
- This unit holds a command object that is used when we have a mouse down in the content
- area of one of our FracAppViews. MacApp calls this to take care of mouse tracking. We
- have a special mouse tracker for several reasons.
-
- For one, we’d like to use a different pattern when dragging the mouse around. The normal
- gray pattern doesn’t show up too well on our colored backgrounds.
-
- Second, we need to constrain the dimensions of the rectangle that gets dragged out. By
- doing this, we make sure that the rectangle that is ultimately defined is proportional
- to the rectangle used for our document.
-
- Finally, after the rectangle is all drawn, and we lift the mouse up, we have to tell
- the TFracAppView what the new selection is. This is because it is the view that knows
- what is selected. When the mouse is lifted, we call the SetSelection method of the
- view with the rectangle.
-
- TAreaSelector is a descendent of TNoChangesCommmand. TNoChangesCommand is a descendent
- of TCommand that says that it doesn’t change the document, and so it can’t be undone.
- All it does is have an INoChangesCommand that sets fCanUndo and fCausesChangs to
- FALSE. Since we just track the mouse, and don’t change the state of the document or
- view, we descend ourselves from TNoChangesCommmand.
-
- --------------------------------------------------------------------------------------------}
-
- INTERFACE
-
- USES UMacApp, UDialog, QDOffScreen, ToolUtils, URectStack, UOffscreen,
- UFracApp;
-
- TYPE
- {------------------------------- Command -------------------------------}
-
- TAreaSelector = OBJECT (TNoChangesCommand)
-
- fOwnerView: TFracAppView; { The view we are tracking in. We need to
- keep track of this so we can tell the
- view to set its selection rectangle
- when we are all done. }
- fPlotHeight: Longint;
- fPlotWidth: Longint; { The dimensions of the document we are
- tracking. These values let us know how
- to constrain mouse tracking, because we
- want it to be proportional to the
- document size. }
-
- PROCEDURE TAreaSelector.IAreaSelector(itsView: TFracAppView;
- itsDocument: TFracAppDocument);
- { Initialize the selection object itself. This basically sets up with
- ICommand, then sets our fields to remember our view. }
-
- FUNCTION TAreaSelector.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
- previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
- { Track the mouse while the button is down in the view. Sets the selection in
- the owning view when we are done. }
-
- PROCEDURE TAreaSelector.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn,
- mouseDidMove: BOOLEAN); OVERRIDE;
- { Feedback that matches better, using the selection pattern. }
-
- PROCEDURE TAreaSelector.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint); OVERRIDE;
- { Constrain the mouse movement to be a rect which matches the screen. }
-
- PROCEDURE TAreaSelector.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: Integer)); OVERRIDE;
- END;
-
- IMPLEMENTATION
-
- {$I UAreaSelector.inc1.p}
-
- END.
-